<!--分类级联选择树-->
<template>
  <span>
    <el-cascader
      ref="categoryCascader"
      v-model="selectedValue"
      style="width: 100%;"
      :options="datas"
      :props="defaultProps"
      clearable
      @change="handleNodeChange">
      <template slot-scope="{ node, data }">
        <span v-if="data.isDeleted===0">{{ data.name }}</span>
        <span v-if="data.isDeleted===1" style="text-decoration: line-through">{{ data.name }}</span>
      </template>
    </el-cascader>
  </span>
</template>
<script>
export default {
  filters: {
  },
  props: {
    value: {
      type: Array,
      required: false,
      default() {
        return []
      }
    },
    isExpandAll: { type: Boolean, default: false } // 是否展开所有节点
  },
  data() {
    return {
      datas: [],
      defaultProps: {
        children: 'children',
        label: 'name',
        value: 'id',
        checkStrictly: true
      },
      currentSelectCategory: {},
      selectedValue: []
    }
  },
  watch: {
    selectedValue: function(val) {
      this.$emit('input', val)
    },
    value: function(val) {
      this.selectedValue = val
    }
  },
  mounted() {},
  created() {
    this.loadContentCategories()
  },
  methods: {
    async loadContentCategories() {
      this.datas.length = 0
      const response = await this.$store.dispatch('upmsCategoryDictTreeByType', '05')
      this.datas = response
    },
    handleNodeChange() {
      var checkedNodes = this.$refs.categoryCascader.getCheckedNodes()
      if (checkedNodes.length > 0) {
        this.$emit('change', checkedNodes[checkedNodes.length - 1].data)
      }
    }
  }
}
</script>
  <style rel="stylesheet/scss" lang="scss" >

  </style>

